$(function(){
	
	document.documentElement.style.fontSize = window.innerWidth/3.75 + 'px';
	
	
	var tel,
		code,
		shareKey='MOON123456789123';////////////////////////////
	$('.getCode-btn').on('click',function(){
		
		var re = /^1\d{10}$/;
        var tel_click = $("input[type='tel']").val();
        tel = tel_click;
        
        if(re.test(tel)){
        	//一分钟之后才能继续获取
        	var count = 60;
		    var countdown = setInterval(CountDown, 1000);
		    function CountDown() {
		        $(".getCode-btn").attr("disabled", true);
		        $(".getCode-btn").css({'background-color':'#939090'});
		        $(".getCode-btn").text(count + "s");
		        if (count == 0) {
		            $(".getCode-btn").text("获取验证码").removeAttr("disabled");
		            $(".getCode-btn").css({'background-color':'#FF4B4A'});
		            clearInterval(countdown);
		        }
		        count--;
		    }
		    //获取验证码
		    $.ajax({
				type: "post",
				url: "/dingding-web/moonActivityAction!getTelePhoneCode.action",
				dataType: "jsonp",
				async: false,
				jsonp: "callback",
				jsonpCallback: "success_jsop",
				data: {
					telephone: tel
				},
				success: function(data) {
					
				}
			});
		    
        }
        else {
        	alert('请输入正确的号码格式');
        }
		
	});
	//点击注册
	$('.register-btn').on('click',function(){
		tel = $('.tel-input').val();
		code = $('.code-input').val();
		
		
		if(tel && code) {
			
			//改成正式
			var baseUrl = "www.pdhz-dddc.cn";
			var appId = 'wxb36d3ec4a768b571';
			
			var wechatUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appId + '&redirect_uri=' + 
				'http%3a%2f%2f'+ baseUrl + 
				'%2fdingding-web%2fmoonActivityAction!weChatValidate.action%3ftelephone%3d'+tel+'%26messageCode%3d' + code +
				'&response_type=code&scope=snsapi_base&state=123&connect_redirect=1#wechat_redirect';
			
			window.location.href = wechatUrl;
		}
		else {
			alert('请输入手机号码和验证码');
		}
	})
	
})